<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>神秘竞拍 | 未知力量的召唤</title>
    <link href="https://fonts.googleapis.com/css2?family=Oxanium:wght@400;700&family=Orbitron:wght@500&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/web3@1.5.2/dist/web3.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/particles.js@2.0.0/particles.min.js"></script>
    <style>
        :root {
            --dark-purple: #0a0612;
            --darker-purple: #05020a;
            --neon-purple: #7b2ff7;
            --neon-blue: #00f0ff;
            --neon-pink: #ff00aa;
            --neon-green: #00ffaa;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background-color: var(--dark-purple);
            color: white;
            font-family: 'Oxanium', sans-serif;
            min-height: 100vh;
            overflow-x: hidden;
            position: relative;
        }

        #particles-js {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem;
            position: relative;
            z-index: 1;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1rem 0;
            border-bottom: 1px solid rgba(123, 47, 247, 0.3);
            margin-bottom: 2rem;
        }

        .logo {
            font-family: 'Orbitron', sans-serif;
            font-size: 2rem;
            background: linear-gradient(45deg, var(--neon-purple), var(--neon-blue));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            text-shadow: 0 0 10px rgba(123, 47, 247, 0.5);
        }

        .connect-wallet {
            background: rgba(123, 47, 247, 0.2);
            border: 1px solid var(--neon-purple);
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 4px;
            cursor: pointer;
            font-family: 'Oxanium', sans-serif;
            transition: all 0.3s ease;
        }

        .connect-wallet:hover {
            background: rgba(123, 47, 247, 0.4);
            box-shadow: 0 0 15px rgba(123, 47, 247, 0.5);
        }

        .wallet-connected {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            background: rgba(0, 240, 255, 0.1);
            border: 1px solid var(--neon-blue);
            padding: 0.5rem 1rem;
            border-radius: 4px;
        }

        .wallet-address {
            font-size: 0.8rem;
            color: var(--neon-blue);
        }

        .main-content {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 2rem;
            margin-top: 2rem;
        }

        .mystery-card {
            background: rgba(15, 10, 30, 0.7);
            backdrop-filter: blur(10px);
            border: 1px solid var(--neon-purple);
            border-radius: 8px;
            padding: 2rem;
            box-shadow: 0 0 15px rgba(123, 47, 247, 0.3);
            transition: box-shadow 0.3s ease;
        }

        .mystery-card:hover {
            box-shadow: 0 0 25px rgba(123, 47, 247, 0.6);
        }

        .glow-effect-blue {
            border-color: var(--neon-blue);
            box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
        }

        .glow-effect-blue:hover {
            box-shadow: 0 0 25px rgba(0, 240, 255, 0.6);
        }

        .glow-effect-pink {
            border-color: var(--neon-pink);
            box-shadow: 0 0 15px rgba(255, 0, 170, 0.3);
        }

        .glow-effect-pink:hover {
            box-shadow: 0 0 25px rgba(255, 0, 170, 0.6);
        }

        h2 {
            font-family: 'Orbitron', sans-serif;
            margin-bottom: 1.5rem;
            color: var(--neon-purple);
            text-shadow: 0 0 5px rgba(123, 47, 247, 0.5);
        }

        h3 {
            font-family: 'Orbitron', sans-serif;
            margin-bottom: 1rem;
            color: white;
            font-size: 1.2rem;
        }

        .mystery-input {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid var(--neon-purple);
            color: white;
            padding: 0.8rem;
            border-radius: 4px;
            width: 100%;
            margin-bottom: 1rem;
            font-family: 'Oxanium', sans-serif;
        }

        .mystery-input::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }

        .mystery-button {
            background: linear-gradient(45deg, var(--neon-purple), var(--neon-blue));
            border: none;
            color: white;
            padding: 0.8rem 1.5rem;
            border-radius: 4px;
            cursor: pointer;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 1px;
            transition: all 0.3s ease;
            font-family: 'Oxanium', sans-serif;
            width: 100%;
            margin-top: 0.5rem;
        }

        .mystery-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(123, 47, 247, 0.4);
        }

        .mystery-button.pink {
            background: linear-gradient(45deg, var(--neon-pink), var(--neon-purple));
        }

        .mystery-button.green {
            background: linear-gradient(45deg, var(--neon-green), var(--neon-blue));
        }

        .auction-info {
            display: flex;
            flex-direction: column;
            gap: 1rem;
            margin-bottom: 1.5rem;
        }

        .info-item {
            display: flex;
            justify-content: space-between;
            border-bottom: 1px dashed rgba(123, 47, 247, 0.3);
            padding-bottom: 0.5rem;
        }

        .info-label {
            color: var(--neon-blue);
        }

        .info-value {
            font-weight: bold;
        }

        .countdown {
            font-size: 1.5rem;
            text-align: center;
            margin: 1rem 0;
            color: var(--neon-green);
            font-family: 'Orbitron', sans-serif;
        }

        .hidden {
            display: none;
        }

        .arcane-symbol {
            position: absolute;
            opacity: 0.1;
            z-index: -1;
        }

        .symbol-1 {
            top: 20%;
            left: 10%;
            font-size: 10rem;
            transform: rotate(15deg);
        }

        .symbol-2 {
            bottom: 10%;
            right: 10%;
            font-size: 8rem;
            transform: rotate(-10deg);
        }

        @media (max-width: 768px) {
            .main-content {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <div id="particles-js"></div>
    
    <!-- 神秘符号装饰 -->
    <div class="arcane-symbol symbol-1">✧</div>
    <div class="arcane-symbol symbol-2">✦</div>

    <div class="container">
        <header>
            <div class="logo">ARCANE AUCTION</div>
            <button id="connectWallet" class="connect-wallet">连接神秘力量</button>
            <div id="walletInfo" class="wallet-connected hidden">
                <span>已连接:</span>
                <span id="walletAddress" class="wallet-address"></span>
            </div>
        </header>

        <div class="main-content">
            <!-- 拍卖信息区 -->
            <div class="mystery-card glow-effect-blue">
                <h2>神秘物品拍卖</h2>
                <div class="auction-info">
                    <div class="info-item">
                        <span class="info-label">当前最高出价:</span>
                        <span class="info-value" id="highestBid">0.5 ETH</span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">最高出价者:</span>
                        <span class="info-value" id="highestBidder">0x...4f3a</span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">拍卖结束:</span>
                        <span class="info-value" id="auctionEnd">2023-12-31 23:59</span>
                    </div>
                </div>
                <div class="countdown" id="countdown">23:59:59</div>
                <p>参与这场神秘拍卖，赢取未知力量的馈赠...</p>
            </div>

            <!-- 用户交互区 -->
            <div class="mystery-card glow-effect-pink">
                <h2>参与仪式</h2>
                
                <!-- 竞拍部分 -->
                <div id="bidSection">
                    <h3>释放你的能量</h3>
                    <input type="number" id="bidAmount" class="mystery-input" placeholder="输入ETH金额" step="0.01" min="0">
                    <button id="placeBid" class="mystery-button">召唤竞拍能量</button>
                </div>

                <!-- 提款部分 -->
                <div id="withdrawSection" style="margin-top: 2rem;">
                    <h3>提取你的能量</h3>
                    <button id="withdrawFunds" class="mystery-button pink">回收ETH能量</button>
                </div>

                <!-- 管理员部分 -->
                <div id="adminSection" style="margin-top: 2rem;" class="hidden">
                    <h3>神秘仪式控制</h3>
                    <button id="endAuction" class="mystery-button green">终结神秘仪式</button>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 初始化粒子背景
        document.addEventListener('DOMContentLoaded', function() {
            particlesJS('particles-js', {
                "particles": {
                    "number": { "value": 80, "density": { "enable": true, "value_area": 800 } },
                    "color": { "value": "#7b2ff7" },
                    "shape": { "type": "circle" },
                    "opacity": { "value": 0.5, "random": true },
                    "size": { "value": 3, "random": true },
                    "line_linked": { "enable": true, "distance": 150, "color": "#5e00ff", "opacity": 0.4, "width": 1 },
                    "move": { "enable": true, "speed": 2, "direction": "none", "random": true, "straight": false }
                },
                "interactivity": {
                    "events": {
                        "onhover": { "enable": true, "mode": "repulse" }
                    }
                }
            });

            // 模拟倒计时
            function updateCountdown() {
                const now = new Date();
                const end = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
                const diff = end - now;
                
                const hours = Math.floor(diff / (1000 * 60 * 60));
                const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
                const seconds = Math.floor((diff % (1000 * 60)) / 1000);
                
                document.getElementById('countdown').textContent = 
                    `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
            }
            
            setInterval(updateCountdown, 1000);
            updateCountdown();

            // 连接钱包功能
            const connectWalletBtn = document.getElementById('connectWallet');
            const walletInfo = document.getElementById('walletInfo');
            const walletAddress = document.getElementById('walletAddress');
            
            connectWalletBtn.addEventListener('click', async () => {
                if (window.ethereum) {
                    try {
                        const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });
                        const account = accounts[0];
                        
                        // 显示连接成功
                        connectWalletBtn.classList.add('hidden');
                        walletInfo.classList.remove('hidden');
                        walletAddress.textContent = `${account.substring(0, 6)}...${account.substring(38)}`;
                        
                        // 检查是否是管理员(这里只是模拟)
                        if (account.toLowerCase() === '0x123...') {
                            document.getElementById('adminSection').classList.remove('hidden');
                        }
                        
                    } catch (error) {
                        console.error("连接钱包失败:", error);
                        alert("连接钱包失败");
                    }
                } else {
                    alert("请安装MetaMask或其他Web3钱包");
                }
            });

            // 竞拍功能
            document.getElementById('placeBid').addEventListener('click', async () => {
                const amount = document.getElementById('bidAmount').value;
                if (!amount || isNaN(amount) || parseFloat(amount) <= 0) {
                    alert("请输入有效的竞拍金额");
                    return;
                }
                
                // 这里应该是调用智能合约的代码
                alert(`模拟竞拍: ${amount} ETH`);
                // 实际实现应该是:
                // const web3 = new Web3(window.ethereum);
                // const contract = new web3.eth.Contract(abi, contractAddress);
                // await contract.methods.bid().send({ from: accounts[0], value: web3.utils.toWei(amount, 'ether') });
            });

            // 提款功能
            document.getElementById('withdrawFunds').addEventListener('click', async () => {
                // 这里应该是调用智能合约的代码
                alert("模拟提款");
                // 实际实现应该是:
                // await contract.methods.withdraw().send({ from: accounts[0] });
            });

            // 结束拍卖功能
            document.getElementById('endAuction').addEventListener('click', async () => {
                // 这里应该是调用智能合约的代码
                alert("模拟结束拍卖");
                // 实际实现应该是:
                // await contract.methods.endAuction().send({ from: accounts[0] });
            });
        });
    </script>
</body>
</html>